package com.woniu.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.entity.PageData;
import com.woniu.entity.dto.OperatorDTO;
import com.woniu.pojo.Operator;
import com.woniu.mapper.OperatorMapper;
import com.woniu.service.IOperatorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sss
 * @since 2023-01-03
 */
@Service
public class OperatorServiceImpl extends ServiceImpl<OperatorMapper, Operator> implements IOperatorService {
    @Autowired
    private OperatorMapper operatorMapper;

    /**
     * 分页搜索查询
     *
     * @param currentPage 当前页
     * @param pageSize    页面大小
     * @param operatorDTO DTO
     * @return PageData
     * @author yemaf
     * @time 2023/01/03 09:54:04
     */
    @Override
    public PageData listSearch(Integer currentPage, Integer pageSize, OperatorDTO operatorDTO) {
        //构建页面
        IPage<Operator> page = new Page<>(currentPage, pageSize);
        //查询数据
        IPage<Operator> operatorIPage = operatorMapper.listSearch(page,operatorDTO);
        //返回数据

        return new PageData(operatorIPage.getTotal(),operatorIPage.getRecords());
    }

    /**
     * 编辑数据
     *
     * @param operator
     * @return Operator
     * @author yemaf
     * @time 2023/01/03 12:04:35
     */
    @Override
    public int edit(Operator operator) {
        int i = operatorMapper.updateById(operator);
        return i;
    }
}
